/**

00000000000000000000000100000001
00000000000000000010000110000001 
00000000001100010010000000100011
00000000000000011100000110000001
00000000001100010010000010100011
00000000000001011010000110000001
00000000001100010010000100100011
00000000000000010101000110000001
00000000001100010010000110100011
00000000000000000100000110000001
00000000001100010010001000100011
00000000000000001011000110000001
00000000001100010010001010100011
00000000000010111110000110000001
00000000001100010010001100100011
00000000000000010101000110000001
00000000001100010010001110100011
00000000000000010100000110000001
00000000001100010010010000100011
00000000000000101100000110000001
00000000001100010010010010100011
00000000000001010010000010000001
00000000000000000010001000000001
11111111111100001000001010010011
00000010010100100101000001100011
00000000000100100000001100010011
00000000000100110101110101100011
00000000010000010000010000110011
00000000000001000010010100000011
00000000011000010000010010110011
00000000000001001010010110000011
00000000101101010101011101100011
00000000000001010000011110010011
00000110111100010010001000100011
00000000000001011000010100010011
00000000100001010010000000100011
00000000000001111000010110010011
00000000100101011010000000100011
00000000000100110000001100010011
00000000000100100000001000010011
00000000000000000000000000110011

*/

//使用排序算法将乱序数组按从大到小的顺序排好
int max() {
    int a[10] = {2, 28, 90, 21, 4, 11, 190, 21, 20, 44};

    int n = 10;
    for (int i = 0; i < n-1; i++) {
        for (int j = (i+1); j < n; j++) {
            if(a[i] < a[j]) {
                int t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
        }
    }
    
    return a[0];
}
/*
 0* li R2 0      #将数组加载到存储空间
 1* li R3 2
 2* sw R3 R2 0
 3* li R3 28
 4* sw R3 R2 4
 5* li R3 90
 6* sw R3 R2 8
 7* li R3 21
 8* sw R3 R2 12
 9* li R3 4
 10* sw R3 R2 16
 11* li R3 11
 12* sw R3 R2 20
 13* li R3 190
 14* sw R3 R2 24
 15* li R3 21
 16* sw R3 R2 28
 17* li R3 20
 18* sw R3 R2 32
 19* li R3 44
 20* sw R3 R2 36
 21* li R1 10    #加载N
 22* li R4 0     #设置i
 23* addi R5 R1 -1
 24* bge R4 R5 6   #跳转到ret
 25* addi R6 R4 1  #设置j
 26* bge R6 R1 13  #跳转到i++
 27* add R8 R2 R4  #计算a[i]的地址   
 28* lw R10 R8 0
 29* add R9 R2 R6  #计算a[j]的地址
 30* lw R11 R9 0
 31* bge R10 R11 7 #跳转到j++
 32* addi R15 R10 0   #交换对应的值t
 33* sw R15 R2 100
 34* addi R10 R11 0
 35* sw R10 R8 0
 36* addi R11 R15 0
 37* sw R11 R9 0
 38* addi R6 R6 1
 39* addi R4 R4 1
 40* ret
*/
